﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition;
using DSCop.Core;
using System.Reflection;
using System.IO;

namespace DSCop
{
    public class RulesContainer
    {
        public CompositionContainer Container { get; set; }

        [ImportMany]
        public IEnumerable<Lazy<IDSRule, IDSRuleMeta>> Rules;

        public RulesContainer()
        {
            AggregateCatalog catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(typeof(Program).Assembly));

            string currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            catalog.Catalogs.Add(new DirectoryCatalog(currentDir));

            //Create the CompositionContainer with the parts in the catalog
            Container = new CompositionContainer(catalog);

            Container.ComposeParts(this);
        }
    }
}
